import { rpcRequest } from './base';
import { request } from 'umi';

const Url = {
  GenerateUploadCertificate: '/sys/oss/generateUploadCertificate',
};

export interface UploadCertificateData {
  keys?: string[];
}

function generateUploadCertificate(data?: UploadCertificateData) {
  return request(Url.GenerateUploadCertificate, {
    method: 'post',
    data,
  }).then(({ data }) => data);
}

export function getOssUploadCert(data?: UploadCertificateData) {
  return generateUploadCertificate(data);
}

export function uploadFileToOss(url: string, ossConfig: any) {
  const params: any = {
    method: 'POST',
    body: ossConfig,
  };
  return fetch(url, params);
}

export function uploadFileToMinio(url: string, params: any) {
  return fetch(url, params);
}

